<template>
  <div class="todo-footer">
    <label>
      <input type="checkbox" :checked="isChecked" @change="changeAllTodoChecked"/>
    </label>
    <span>
          <span>已完成{{checkedNum}}</span> / 全部{{totalNum}}
        </span>
    <button class="btn btn-danger" @click="deleteALlCheckedTodo">清除已完成任务</button>
  </div>
</template>

<script lang="ts">
export default {
  name: "Footer"
}
</script>
<script lang="ts" setup>
import useCRUD from "./hooks/useCRUD";
import {defineProps} from "vue";
import {TPList} from "../../todo";
const todoListProps = defineProps<{
  todoList:TPList,
  changeAllTodoChecked:Function,
  deleteALlCheckedTodo:Function
}>()
//导出：计算总数，计算已选，是否选中的功能
const {totalNum,checkedNum,isChecked} = useCRUD(todoListProps)
</script>

<style scoped>
/*footer*/
.todo-footer {
  height: 40px;
  line-height: 40px;
  padding-left: 6px;
  margin-top: 5px;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}
</style>